Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce slice allocations during unique insertions #705

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Dec 25, 2024

Just reduce some really easy to avoid slice allocations for every unique
insertion:

  • No reason to have requiredV3states allocated every time a new unique
    opts is validated. It never changes.

  • Leave missingStates unallocated by default. Most of the time a
    unique insertion will have have no missing unique states, so this
    skips a unique allocation completely the overwhelmingly majority of
    the time.

@brandur brandur force-pushed the brandur-reduce-allocations branch from e905811 to 9859d7a Compare December 25, 2024 19:30
Just reduce some really easy to avoid slice allocations for every unique
insertion:

* No reason to have `requiredV3states` allocated every time a new unique
  opts is validated. It never changes.

* Leave `missingStates` unallocated by default. Most of the time a
  unique insertion will have have no missing unique states, so this
  skips a unique allocation completely the overwhelmingly majority of
  the time.
@brandur brandur force-pushed the brandur-reduce-allocations branch from 9859d7a to d5ed285 Compare December 25, 2024 19:33
Copy link
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! Thanks

@brandur brandur merged commit f88dfff into master Dec 27, 2024
10 checks passed
@brandur brandur deleted the brandur-reduce-allocations branch December 27, 2024 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants